/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package haw.pr2.A2a.implementations;

import haw.pr2.A2a.interfaces.*;
import static haw.pr2.A2a.implementations.UtilityclassValues.*;
/**
 *
 * @author Fabian Heidorn, Alexander Kaack
 */
class MassInKg extends AbstractScalar<Mass> implements Mass, Comparable<Mass> {

    private final double massInKg;
    
    MassInKg(double massInKg) {
        this.massInKg=massInKg;
    }

    @Override
    public Mass inverse() {
        return new MassInKg(-this.kg());
    }

    @Override
    public Mass add(Mass value) {
        return new MassInKg(this.kg()+value.kg());
    }

    @Override
    public Mass sub(Mass value) {
        return new MassInKg(this.kg()-value.kg());
    }

    @Override
    public Mass mul(double value) {
        return new MassInKg(this.kg()*value);
    }

    @Override
    public Mass div(double value) {
        return new MassInKg(this.kg()/value);
    }

    @Override
    public double div(Mass value) {
        return this.kg()/value.kg();
    }

    @Override
    public boolean isZero() {
        return this.equals(ZERO_MASS);
    }

    @Override
    public boolean isValid() {
        return true;
    }

    @Override
    public double kg() {
        return this.massInKg;
    }

    @Override
    public double g() {
        return this.kg()*KG_IN_G;
    }

    @Override
    public double t() {
        return this.kg()*KG_IN_T;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (!(obj instanceof Mass)) return false;
        return this.compareTo((Mass)obj) == 0;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 17 * hash + (int) (Double.doubleToLongBits(this.massInKg) ^ (Double.doubleToLongBits(this.massInKg) >>> 32));
        return hash;
    }
    
    @Override
    public int compareTo(Mass m) {
       return Double.compare(this.kg(),m.kg());
    }
    
    // @Override
    public static Mass valueOf(double value) {
        return new MassInKg(value);
    }

    @Override
    public double toDouble() {
        return this.kg();
    }

    @Override
    public Power mulA(Acc a) {
        return new PowerInKw(this.mul(a.ms2()).kg());
    }

    @Override
    public Force mulAtoF(Acc a) {
        return new ForceInN(this.mul(a.ms2()).kg());
    }
}
